<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    

<!DOCTYPE>
<html>
<!--后台管理中的目标库审核-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../bootstrap-table/bootstrap.min.css" />
<link rel="stylesheet" href="../../bootstrap-table/bootstrap-table.css">
<link rel="stylesheet" href="../../css/other.css" />
<link rel="stylesheet" href="../../css/top.css" />
<link rel="stylesheet" href="../../css/home.css" />
<link rel="stylesheet" href="../../css/window.css" />
<link rel="stylesheet" href="../../css/datepicker.css" />
<link rel="stylesheet" href="../../font-awesome-4.6.3/css/font-awesome.min.css" />
<script src="../../js/jquery.min.js"></script>
<script src="../../js/top_control.js"></script>
<script src="../../js/target_review.js"></script>
<script src="../../js/bootstrap-datepicker.js"></script>
<script src="../../js/window.js"></script>
<script src="../../bootstrap-table/bootstrap-table.js"></script>
<script src="../../bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<title>智行校园-精准化服务平台</title>
</head>
<body class="background">
<input  type="hidden" value="目标审核" id="the_goal"/>
<input  type="hidden" value="1323" id="user_id"/>
<div class="container ">
	<div class="targets_left col-2" style="margin-left:0;width:10em"></div>
	<div class="targets_right " style="width:calc(100% - 13.7em);margin-top:0em">
          <h3 style="width:100%">目标库管理</h3>
		      <div class="time_choose">
		      <label>搜索关键词：</label>
		      <input style="float:left;min-width:14em" placeholder="请输入目标名称"  id="data_search" />
		      <br/><br/>
		      <label >发布时间：</label>
		      <input type="text" id="data_start"><i class="fa fa-calendar" aria-hidden="true"></i>
		                            至     <input type="text"  id="data_end"><i class="fa fa-calendar" aria-hidden="true"></i>
		      <button class="search_button">搜索</button></div>
		      <a class="add_target" href="add_target.jsp" style="margin-top:1em;margin-bottom:-1em">教师目标审核设置</a>
		    <div class="points_buttons"></div>
			<table id="the_table" ></table>
	</div>
	<div id="table_dialog" style="display:none;" class="table_dialog"></div>
	<div id="review_dialog" style="display:none;" class="table_dialog">
	   <div class="dialog"></div>
	    <div class="my_dialog" style="top:30%;left:30%" id="review_set">
	        <h4>目标审核设置</h4><i class="fa fa-times"></i>
	        <div class="target_dialog" style="padding: 0.8em 2em;background:white">
	           <table class="my_table" cellspacing="0" cellpadding="0" >
					<tbody>
					   <tr>
							<td>向权限内发出的目标</td>
							<td><input type="radio" name="set_style1" value="1"/>手动审核     <input type="radio" name="set_style1"  value="0" style="margin-left:1.5em"/>自动审核      </td>
						</tr>
						<tr>
							<td>向权限外发出的目标</td>
							<td><input type="radio" name="set_style2" value="1" />手动审核     <input type="radio"  name="set_style2" value="0" style="margin-left:1.5em" />自动审核    </td>
						</tr>
					</tbody>
				</table>
				<button class="make_sure" style=" margin: 1.5em 16em;padding: 0.3em 1em;">确定</button>
				<div  class="clear"></div>
	        </div>
	    </div>
	</div>
	<div class="clear"></div>
</div>
<script src="../../js/leftcol_control.js"></script>
<script>
var user_id=$('input#user_id').attr('value');
$(function(){
	$('input#data_end,input#data_start').datepicker({
		format: 'yyyy-mm-dd'
	});
var data=[{"type":"0","name":"待审核"},{"type":"1","name":"已通过"},{"type":"-1","name":"未通过"}];
var colums = [["id", "t_name","t_describe", "t_buider","t_object","t_build_time","operate"],
              ["序号", "目标名称",  "描述", "发布人","发布对象" ,"发布时间","操作"] ];
	for(var i=0;i<data.length;i++){
		   if(i==0)
			 $('div.points_buttons').append('<button class="selected" value="'+data[i].type+'">'+data[i].name+'</button>');
	       else
			 $('div.points_buttons').append('<button value="'+data[i].type+'">'+data[i].name+'</button>');
		}
		 paint_table("the_table","../../jsp/target/target_review.json?param2="+$('div.points_buttons button.selected').attr('value')+" &param1= "+user_id,colums,8, true,'',onClickRow);
		 $('div.points_buttons button').click(function() {
			    var the_type=$(this).attr('value');
				$(this).addClass('selected').siblings().removeClass('selected');
				$('#the_table').bootstrapTable('refresh',{
					url:'../../jsp/target/target_review.json? param2='+the_type+' &param1='+user_id
				});
			});
	$('div.targets_right button.search_button').click(function(){
		var search_data=$('div.targets_right input#data_search').val();
		var start_data=$('div.targets_right input#data_start').val();
		var end_data=$('div.targets_right input#data_end').val();
		if(search_data==''&&(start_data!=''&&end_data!=''))
			$('#the_table').bootstrapTable('refresh',{
				url:"../../jsp/target/target_review.json? param2= "+$('div.points_buttons button.selected').attr('value')+" & param3="+start_data+" & param4="+end_data+" & param1="+user_id
			});
		else if(search_data!=''&&(start_data==''||end_data==''))
			$('#the_table').bootstrapTable('refresh',{
				url:"../../jsp/target/target_review.json? param2= "+$('div.points_buttons button.selected').attr('value')+" & param3="+search_data+" & param1="+user_id
			});
		else if(search_data!=''&&start_data!=''&&end_data!='')
			$('#the_table').bootstrapTable('refresh',{
				url:"../../jsp/target/target_review.json? param2= "+$('div.points_buttons button.selected').attr('value')+" & param3="+search_data+" & param4="+start_data+" & param4="+end_data+" & param1="+user_id
			});
		else
			 win.alert("系统提示","请先填写筛选条件！");
	
	});
	$('div.targets_right a.add_target').click(function(){
		$('div#review_dialog ').show('fast');
		$('div#review_dialog div#review_set i.fa-times').click(function(){
			$('div#review_dialog ').hide('fast');
		});
		$('div#review_dialog div#review_set button.make_sure').click(function(){
			var inside=$('input[name="set_style1"]:checked').attr('value');
			var outside=$('input[name="set_style2"]:checked').attr('value');
			$('div#review_dialog ').hide('fast');
		});
		return false;
	});
 });
function paint_table(id, data,colums, number, pagination,height,onClickRow) {
	var colum = [];
	for (var i = 0; i < colums[0].length; i++){
		if(i==(colums[0].length-1))
 		   colum[i]={field:colums[0][i],title:colums[1][i],valign:"middle",align:"center",formatter:actionFormatter_radio,events: operateEvents_radio};
 		else
    	   colum[i]={field:colums[0][i],title:colums[1][i],valign:"middle",align:"center"};
	}
	$('#' + id).bootstrapTable({
		url : data,
		columns : colum,
		height:height,
		sidePagination : 'server',
		pagination : pagination,
		onClickRow:onClickRow,
		pageSize : number,
		search : false,
		searchOnEnterKey : true,
		locale : 'zh-CN'
	});		
}

  function onClickRow(row, $element){
	  target_review(row.t_id,'table_dialog',$('div.header_tright img').attr('src'), user_id,$('div.header_tright a:eq(2)').text(),$('div.points_buttons button.selected').attr('value'));
	}

function actionFormatter_radio(value, row, index) {
	      if(value=='0')
		    return ['<input type="radio" name="review'+row.t_id+'" value="1"> 通过  &nbsp&nbsp <input type="radio" value="-1" name="review'+row.t_id+'" style="margin-left:0.5em"> 不通过'].join('');
	      else if(value=='1'){
			    return ['<input type="radio"   name="review'+row.t_id+'" value="1" checked="checked"> 通过  &nbsp&nbsp <input type="radio"  value="-1" name="review'+row.t_id+'" style="margin-left:0.5em"> 不通过'].join('');
	      }else
			    return ['<input type="radio" name="review'+row.t_id+'" value="1"> 通过  &nbsp&nbsp<input type="radio"   value="-1" name="review'+row.t_id+'" style="margin-left:0.5em" checked="checked"> 不通过'].join('');
	}

 window.operateEvents_radio = {
    		'click input[name*="review"]': function (e, value, row, index) {
    			e.stopPropagation();
    			alert($('input[name="review'+row.t_id+'"]:checked').attr('value'));
   				    $.ajax({
    		    	   url:'',
    		    	   data:{param1:user_id,param2:row.t_id,param3:$('input[name="review'+row.t_id+'"]:checked').attr('value')},
    		    	   type:'post',
    		    	   success:function(){
    		    		   win.alert("系统提示","操作成功！");
    		    		   $('div.body-panel p.btns button:eq("0")').unbind('click').click(function(){
	    	    				 win.close();
	    	    			 });
	    	    		    setTimeout("$('div.win').css('display','none')",1000);	
    		    		   $('#the_table').bootstrapTable('refresh',{
    							url:'../../jsp/target/target_review.json? param2='+$('div.points_buttons button.selected').attr('value')+' &param1='+user_id
    						});
    		    	   }
    		           });
    		  }
    	  };

</script>
</body>
</html>